package com.loozb.thread5;

/**
 * 单例模式
 *
 * @author 龙召碧
 * @create 2018-02-06 9:29
 **/
public class Singleton {

    /**
     * 使用private，防止外面实例化
     */
    private Singleton() {

    }

    private static class SingletonHolder {
        private static Singleton instance = new Singleton();
    }

    public static Singleton getInstance() {
        return SingletonHolder.instance;
    }

    public static void main(String[] args) {
        Singleton singleton = Singleton.getInstance();
        System.out.println(singleton);
    }
}
